package Task2;

import java.util.ArrayList;

public class Queue {
	private ArrayList<Email> list;

	public Queue() {
		list = new ArrayList<Email>();
	}

	public synchronized void addEmail(Email email) {
		this.notify();
		list.add(email);
	}

	public synchronized void removeEmail() {
		while (list.size() == 0) {
			try {
				this.wait();
			} catch (InterruptedException e) {
			}
		}
		list.remove(0);
	}

	public synchronized ArrayList<Email> getEmails() {
		return list;
	}
}